package com.getpebble.android.framework.protocol.inbound;

import com.getpebble.android.bluetooth.protocol.ProtocolMessage;
import com.getpebble.android.framework.protocol.EndpointId;

public class PblInboundMusicMessage extends PblInboundMessage {
    private MusicControlCommand mMusicControlCmd;

    public enum MusicControlCommand {
        UNKNOWN((byte) 0),
        PLAY_PAUSE((byte) 1),
        PAUSE((byte) 2),
        PLAY((byte) 3),
        NEXT_TRACK((byte) 4),
        PREVIOUS_TRACK((byte) 5),
        VOLUME_UP((byte) 6),
        VOLUME_DOWN((byte) 7),
        GET_NOW_PLAYING((byte) 8);
        
        private byte command;

        private MusicControlCommand(byte command) {
            this.command = command;
        }

        public static MusicControlCommand fromByte(byte b) {
            for (MusicControlCommand r : values()) {
                if (r.command == b) {
                    return r;
                }
            }
            return UNKNOWN;
        }
    }

    public PblInboundMusicMessage(ProtocolMessage message) {
        super(message);
        this.mMusicControlCmd = MusicControlCommand.fromByte(message.getDataBuffer().get());
    }

    public MusicControlCommand getMusicControlCommand() {
        return this.mMusicControlCmd;
    }

    public EndpointId getId() {
        return EndpointId.MUSIC_CONTROL;
    }

    protected int getMinSize() {
        return 1;
    }
}
